"""
@Project ：python
@File    ：07-继承.py
@IDE     ：PyCharm
@Author  ：DongCha
@Date    ：2024/4/10 010 19:46
"""


# 单继承基本语法：
# class 子类名(父类名):
#     类内容体
class Phone:
    IMEI = "1231321321321"  # 序列号
    producer = "DongCha"  # 厂商

    def call_by_4g(self):
        print("4g通话")


class Phone2024(Phone):
    face_id = True  # 面部识别

    def call_by_5g(self):
        print("5g通话")


phone = Phone2024()
print(phone.producer)
print(phone.face_id)
phone.call_by_4g()
phone.call_by_5g()


# 多继承基础语法：
# class 子类名(父类名1, 父类名2, 父类名3, ..., 父类名N):
#     类内容体
class NFCReader:
    nfc_type = "瑞克五代"
    producer = "顶针"

    def read_card(self):
        print("读取NFC")

    def write_card(self):
        print("写入NFC")


class RemoteControl:
    rc_type = "红外遥控"

    def control(self):
        print("红外遥控")


class MyPhone(Phone2024, NFCReader, RemoteControl):
    pass  # 补全语法


my_phone = MyPhone()
my_phone.call_by_4g()
my_phone.call_by_5g()
my_phone.control()
my_phone.read_card()
my_phone.write_card()

# 如果多个属性或方法同名，默认以继承顺序（从左到右）为优先级：先继承的保留，后继承的被覆盖
print(my_phone.producer)
